package com.cycling.app.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.cycling.app.R;
import com.cycling.app.utils.DribblePrefs;

/**
 * Created by LiZhanPing on 2017/5/6.
 */

public class UseActivity extends BaseActivity {

    private EditText edit_code;

    @Override
    public int layoutResId() {
        return R.layout.activity_use;
    }

    @Override
    public void onActivityCreate(@Nullable Bundle savedInstanceState) {
        setTitle(R.string.app_name);
        edit_code = (EditText) findViewById(R.id.edit_code);
    }

    public void useNow(View view) {
        String code = edit_code.getText().toString();

        if (TextUtils.isEmpty(code)) {
            Toast.makeText(UseActivity.this, "请输入车牌号", Toast.LENGTH_SHORT).show();
            return;
        }

        if (!DribblePrefs.get().isLoggedIn()) {
            Toast.makeText(UseActivity.this, "请先登录", Toast.LENGTH_SHORT).show();
            startActivity(new Intent(UseActivity.this, LoginActivity.class));
            return;
        }

        startActivity(new Intent(UseActivity.this, CheckActivity.class)
                .putExtra("code", code));
    }
}
